package com.run.merchant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.run.common.annotation.Log;
import com.run.common.core.controller.BaseController;
import com.run.common.core.domain.AjaxResult;
import com.run.common.enums.BusinessType;
import com.run.merchant.domain.ApplyInfo;
import com.run.merchant.service.IApplyInfoService;
import com.run.common.utils.poi.ExcelUtil;
import com.run.common.core.page.TableDataInfo;

/**
 * 代取员认证申请Controller
 * 
 * @author run
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/merchant/infoapply")
public class ApplyInfoController extends BaseController
{
    @Autowired
    private IApplyInfoService applyInfoService;

    /**
     * 查询代取员认证申请列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplyInfo applyInfo)
    {
        startPage();
        List<ApplyInfo> list = applyInfoService.selectApplyInfoList(applyInfo);
        return getDataTable(list);
    }

    /**
     * 导出代取员认证申请列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:export')")
    @Log(title = "代取员认证申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplyInfo applyInfo)
    {
        List<ApplyInfo> list = applyInfoService.selectApplyInfoList(applyInfo);
        ExcelUtil<ApplyInfo> util = new ExcelUtil<ApplyInfo>(ApplyInfo.class);
        util.exportExcel(response, list, "代取员认证申请数据");
    }

    /**
     * 获取代取员认证申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return success(applyInfoService.selectApplyInfoByApplyId(applyId));
    }

    /**
     * 新增代取员认证申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:add')")
    @Log(title = "代取员认证申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplyInfo applyInfo)
    {
        return toAjax(applyInfoService.insertApplyInfo(applyInfo));
    }

    /**
     * 修改代取员认证申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:edit')")
    @Log(title = "代取员认证申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplyInfo applyInfo)
    {
        return toAjax(applyInfoService.updateApplyInfo(applyInfo));
    }

    /**
     * 删除代取员认证申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infoapply:remove')")
    @Log(title = "代取员认证申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(applyInfoService.deleteApplyInfoByApplyIds(applyIds));
    }
}
